home *** CD-ROM | disk | FTP | other *** search
-
-
-
-
-
-
-
- PRODUCT : Borland C++ NUMBER : 1035
- VERSION : 3.1
- OS : ALL
- DATE : October 23, 1992 PAGE : 1/6
-
- TITLE : Using the Template version of the Class Library.
-
-
-
-
-
- This document provides an overview of the various causes of the
- the "Illegal Structure Operation..." error message generated when
- using template classes, template functions, and/or BIDS.
-
-
- Consider the classic function template max():
-
- template <class T>
- T max(T x, T y)
- {
- return (x > y) ? x : y ;
- }
-
-
- In order to pass in a user-defined type into this function, say
- for instance class Foo{...};, Foo would need to have an
- appropriate overloaded operator >() defined. If Foo did not have
- such a function, passing in Foo objects would cause illegal or
- undefined behavior because there is no comparison mechanism
- for the compiler to use for Foo types. The same rules apply when
- using the BIDS class library.
-
-
- If you are using the template-based BIDS library, you'll see
- advertised in the manuals that the template-based containers can
- contain ANY type of object, default or user-defined, not just
- those derived from the Object class (which is the requirement for
- using the non-template base container classes). This is true,
- although there are requirements for user-defined types which are
- not clearly defined in the documentation. If these requirements
- are not met, you will see compiler error messages such as "
- Illegal structure operation in Base<T>::find<T> " or " Illegal
- structure operation in Base<T>::findPred<T> ".
-
-
- The following table illustrates what operators and functions need
- to be provided for your type according to which BIDS container
- you use. For example, in order to store a user-defined class in
- BI_BagAsVector<foo>, foo must have operator==( ) defined
-
-
- ---------------------------------------------------------------- +
-
-
-
-
-
-
-
-
-
-
-
-
-
- PRODUCT : Borland C++ NUMBER : 1035
- VERSION : 3.1
- OS : ALL
- DATE : October 23, 1992 PAGE : 2/6
-
- TITLE : Using the Template version of the Class Library.
-
-
-
-
- | | | | | Constructor |
- BIDS | == | != | < | isSortable |Default| Copy |
- -----------------------|----|----|---|------------|-------|------|
- BI_VectorImp | | | | | | |
- -----------------------|----|----|---|------------|-------|------|
- BI_CVectorImp | | | | | | |
- -----------------------|----|----|---|------------|-------|------|
- BI_SVectorImp | X | | X | | X | X |
- -----------------------|----|----|---|------------|-------|------|
- BI_IVectorImp | | | | | | |
- -----------------------|----|----|---|------------|-------|------|
- BI_ICVectorImp | X | | | X | | |
- -----------------------|----|----|---|------------|-------|------|
- BI_ISVectorImp | X | | X | X | | |
- -----------------------|----|----|---|------------|-------|------|
- | | | | | | |
- -----------------------|----|----|---|------------|-------|------|
- BI_ListImp | X | | | | | X |
- -----------------------|----|----|---|------------|-------|------|
- BI_SListImp | X | X | X | | X | X |
- -----------------------|----|----|---|------------|-------|------|
- BI_IListImp | X | | | | | |
- -----------------------|----|----|---|------------|-------|------|
- BI_ISListImp | X | X | X | | X | X |
- -----------------------|----|----|---|------------|-------|------|
- | | | | | | |
- -----------------------|----|----|---|------------|-------|------|
- BI_DoubleListImp | X | | | | | |
- -----------------------|----|----|---|------------|-------|------|
- BI_SDoubleListImp | X | X | X | | X | X |
- -----------------------|----|----|---|------------|-------|------|
- BI_IDoubleListImp | X | | | | | |
- -----------------------|----|----|---|------------|-------|------|
- BI_ISDoubleListImp | X | X | X | | X | X |
- -----------------------|----|----|---|------------|-------|------|
- | | | | | | |
- -----------------------|----|----|---|------------|-------|------|
- BI_ArrayAsVectorImp | | | | | X | X |
- -----------------------|----|----|---|------------|-------|------|
- BI_ArrayAsVector | X | | | | X | X |
- -----------------------|----|----|---|------------|-------|------|
- BI_SArrayAsVector | X | | X | X | X | X |
- -----------------------|----|----|---|------------|-------|------|
-
-
-
-
-
-
-
-
-
-
-
-
-
- PRODUCT : Borland C++ NUMBER : 1035
- VERSION : 3.1
- OS : ALL
- DATE : October 23, 1992 PAGE : 3/6
-
- TITLE : Using the Template version of the Class Library.
-
-
-
-
- BI_IArrayAsVector | X | | | X | | |
- -----------------------|----|----|---|------------|-------|------|
- BI_ISArrayAsVector | X | | X | X | | |
- -----------------------|----|----|---|------------|-------|------|
- | | | | | | |
- -----------------------|----|----|---|------------|-------|------|
- BI_StackAsVectorImp | | | | | X | X |
- -----------------------|----|----|---|------------|-------|------|
- BI_StackAsVector | X | | | | X | X |
- -----------------------|----|----|---|------------|-------|------|
- BI_IStackAsVector | X | | | | X | |
- -----------------------|----|----|---|------------|-------|------|
- BI_StackAsListImp | | | | | X | X |
- -----------------------|----|----|---|------------|-------|------|
- BI_StackAsList | | | | | X | X |
- -----------------------|----|----|---|------------|-------|------|
- BI_IStackAsList | X | | | | X | |
- -----------------------|----|----|---|------------|-------|------|
- | | | | | | |
- -----------------------|----|----|---|------------|-------|------|
- BI_DequeAsVectorImp | | | | | X | X |
- -----------------------|----|----|---|------------|-------|------|
- BI_DequeAsVector | | | | | X | X |
- -----------------------|----|----|---|------------|-------|------|
- BI_IDequeAsVector | X | X | | | X | |
- -----------------------|----|----|---|------------|-------|------|
- BI_DequeAsDoubleListImp| | | | | X | X |
- -----------------------|----|----|---|------------|-------|------|
- BI_DequeAsDoubleList | X | X | | | X | X |
- -----------------------|----|----|---|------------|-------|------|
- BI_IDequeAsDoubleList | | | | | | |
- -----------------------|----|----|---|------------|-------|------|
- | | | | | | |
- -----------------------|----|----|---|------------|-------|------|
- BI_QueueAsVector | | | | | X | X |
- -----------------------|----|----|---|------------|-------|------|
- BI_IQueueAsVector | | | | | | |
- -----------------------|----|----|---|------------|-------|------|
- BI_QueueAsDoubleList | X | X | | | X | X |
- -----------------------|----|----|---|------------|-------|------|
- BI_IQueueAsDoubleList | | | | | | |
- -----------------------|----|----|---|------------|-------|------|
- | | | | | | |
-
-
-
-
-
-
-
-
-
-
-
-
-
- PRODUCT : Borland C++ NUMBER : 1035
- VERSION : 3.1
- OS : ALL
- DATE : October 23, 1992 PAGE : 4/6
-
- TITLE : Using the Template version of the Class Library.
-
-
-
-
- -----------------------|----|----|---|------------|-------|------|
- BI_BagAsVectorImp | | | | | X | X |
- -----------------------|----|----|---|------------|-------|------|
- BI_BagAsVector | | | | | X | X |
- -----------------------|----|----|---|------------|-------|------|
- BI_IBagAsVector | X | X | | X | | |
- -----------------------|----|----|---|------------|-------|------|
- BI_SetAsVector | X | | | | X | X |
- -----------------------|----|----|---|------------|-------|------|
- BI_ISetAsVector | X | X | | X | | |
- -----------------------------------------------------------------+
-
-
- For any user-defined type that you put into the following
- containers, an operator==( ) must be defined for your type in
- order for the container to decide whether two objects are equal:
-
- BI_BagAsVector<T>
- BI_BagAsVectorIterator<T>
- BI_ArrayAsVector<T>
- BI_SetAsVector<T>
- BI_StackAsList<T>
- BI_ListImp<T>
-
-
- For any user-defined type that you put into the following
- containers, you need to define operator !=() for the class for
- comparison purposes, as well as link in BIDSx.LIB:
-
- BI_QueueAsDoubleList<T>
- BI_DequeAsDoubleList<T>
- BI_DoubleListImp<T>
-
-
- For any type that you put into a sortable container (BI_S...), you
- must define an operator<( ) as well for similar reasons.
-
-
- NOTE: As of 6/4/92, this is only a partial list. Any added
- information from programmers would be appreciated. Please fax
- comments/suggestions to 'C++ Technical Support Attention DBA' at
- (408)439-9100. Thank you.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- PRODUCT : Borland C++ NUMBER : 1035
- VERSION : 3.1
- OS : ALL
- DATE : October 23, 1992 PAGE : 5/6
-
- TITLE : Using the Template version of the Class Library.
-
-
-
-
- Here's an example Data class that implements ALL the necessary
- overloaded operators to instantiate most BIDS classes (not all are
- necessarily required in all cases):
-
- struct mydata
- {
- char* data;
- int size;
- mydata(int sz, char* s){ data = new char[sz]; strcpy(data,s);}
- mydata(){data = new char[20];strcpy(data,"default");}
- mydata(const mydata&); //copy constructor
- ~mydata(){delete data;}
- mydata& operator=(const mydata&); //conversion operator
- int operator==(const mydata&);
- int operator<(const mydata&);
- int operator>(const mydata&);
- int operator!=(const mydata&);
- };
-
- mydata& mydata::operator=(const mydata& a)
- {
- if (this!= &a)
- {
- delete data;
- data = new char[size=a.size];
- strcpy(data,a.data);
- }
- return *this;
- }
-
-
- int mydata::operator==(const mydata& a)
- {
- if (strcmp(data,a.data) == 0)
- return 1;
- else
- return 0;
- }
-
-
- int mydata::operator!=(const mydata& a)
- {
- if (strcmp(data,a.data) != 0)
-
-
-
-
-
-
-
-
-
-
-
-
-
- PRODUCT : Borland C++ NUMBER : 1035
- VERSION : 3.1
- OS : ALL
- DATE : October 23, 1992 PAGE : 6/6
-
- TITLE : Using the Template version of the Class Library.
-
-
-
-
- return 1;
- else
- return 0;
- }
-
-
- int mydata::operator<(const mydata& a)
- {
- if(strcmp(data,a.data) < 0)
- return 1;
- else
- return 0;
- }
-
-
- int mydata::operator>(const mydata& a)
- {
- if(strcmp(data,a.data) > 0)
- return 1;
- else
- return 0;
- }
-
-
- mydata::mydata(const mydata& a)
- {
- data = new char[size=a.size];
- strcpy(data,a.data);
- }
-
-
-
-
- DISCLAIMER: You have the right to use this technical information
- subject to the terms of the No-Nonsense License Statement that you
- received with the Borland product to which this information
- pertains.
-
-
-
-
-
-
-
-
-
-
-
-
-